package
{
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.events.ProgressEvent;
	import flash.net.FileReference;
	import flash.net.URLRequest;
	
	import root.TestRoot;
	
	public class TestDownload extends TestRoot
	{
		public function TestDownload()
		{
			super();

			this.addEventListener(MouseEvent.CLICK, onMouseClick);
		}
		
		public	function	onMouseClick(evt:MouseEvent):void{
			var fileRef:FileReference = new FileReference();
			var urlReq:URLRequest = new URLRequest("http://www.163.com");
			fileRef.addEventListener(Event.SELECT, onSelect);
			fileRef.addEventListener(Event.CANCEL, onCancel);
			fileRef.addEventListener(ProgressEvent.PROGRESS, onProgress);
			fileRef.addEventListener(Event.COMPLETE, onDownComplete);
			fileRef.download(urlReq, "163.html");
		}
		
		public	function	onSelect(evt:Event):void{
			trace("select");
		}
		
		public	function	onCancel(evt:Event):void{
			trace("cancel");
		}
		
		public	function	onProgress(evt:ProgressEvent):void{
			trace("loaded:"+evt.bytesLoaded+",total:"+evt.bytesTotal);
		}
		
		public	function	onDownComplete(evt:Event):void{
			trace("download complete");
		}
	}
}